Skip to content

Preserve byte escapes when unquoting tokens - #484

Merged
alecthomas merged 1 commit into
alecthomas:masterfrom
jakezwang:fix/unquote-byte-escapes
Sep 21, 2026
Merged

alecthomas merged 1 commit into
alecthomas:masterfrom
jakezwang:fix/unquote-byte-escapes

Conversation

@jakezwang

Copy link
Copy Markdown
Contributor

Unquote currently writes every decoded escape as a Unicode rune. Hexadecimal and octal byte escapes above 127 therefore change bytes: "\xff" becomes UTF-8 c3 bf, and "\xc3\xbf" becomes ÿ instead of ÿ.

Honor the multibyte result from strconv.UnquoteChar, preserving byte escapes while continuing to encode Unicode characters normally. Add public parser regressions covering byte, Unicode, mixed, and ASCII inputs.

Validation: four regressions fail before the fix. Full go test -race ./..., all example tests, and the CI-pinned golangci-lint 2.12.2 pass with Go 1.26.6.

@alecthomas
alecthomas merged commit ea5eb7a into alecthomas:master Sep 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants